package lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * @author by 何坤
 * @Classname Charter02Test
 * @Description TODO
 * @Date 2019/10/12 10:15
 */
public class Charter02Test {
    public static void main(String[] args) {
        /*List<Integer> list = map(Arrays.asList("lambda", "in", "action"), (String s) -> s.length());
        list.stream().forEach(System.out::println);

        int number = 123;
        Runnable r = () -> System.out.println(number);
        r.run();*/

    }

    public static <T, R> List<R> map(List<T> list, Function<T, R> f){
        List<R> results = new ArrayList<>();
        for (T s : list){
            results.add(f.apply(s));
        }
        return results;
    }


}
